import { CUqBase } from 'uq-app'
import { LogisticCenter, ReturnQueryProductByIDRet } from 'uq-app/uqs/BzTicket'
import { VLogsticCenter } from './VLogsticCenter'
export class CLogsticCenter extends CUqBase {
  newNo: string
  LogsticCenterList: LogisticCenter[]
  LogsticCenter: ReturnQueryProductByIDRet
  status: number

  protected async internalStart() {
    await this.loadList()
    this.openVPage(VLogsticCenter)
  }
  // newProduct = async () => {
  //   let { BzTicket } = this.uqs
  //   this.newNo = await BzTicket.IDNO({ ID: BzTicket.Product })
  //   this.status = 1
  //   this.openVPage(VProductNew)
  // }

  onNewSubmit = async (data: LogisticCenter) => {
    if (!data.no) {
      alert('请输入编号')
    }
    // let { BzTicket } = this.uqs;
    // let ret = await BzTicket.Acts(
    //     {
    //         product: [data],
    //     }
    // );
    await this.loadList()
    this.replaceVPage(VLogsticCenter)
  }

  // editProduct = async (item: LogsticCenter) => {
  //   let { BzTicket } = this.uqs
  //   this.product = await (
  //     await BzTicket.QueryProductByID.query({ id: item.id })
  //   ).ret[0]
  //   this.openVPage(VProductEdit)
  // }

  // onEditSubmit = async (data: Product) => {
  //   let { BzTicket } = this.uqs
  //   await BzTicket.UpdateProduct.submit({
  //     id: this.product.id,
  //     name: data.name,
  //     version: data.version,
  //     desc: data.desc,
  //     preNo: data.preNo,
  //     isbackend: data.isbackend,
  //     backVersionNo: data.backVersionNo,
  //     status: data.status,
  //   })
  //   await this.loadList()
  //   this.replaceVPage(VProduct)
  // }

  private async loadList() {
    let { BzTicket } = this.uqs
    let productList = await BzTicket.QueryID<LogisticCenter>({
      ID: BzTicket.LogisticCenter,
      page: {
        start: 0,
        size: 100,
      },
    })
    this.runInAction(() => {
      this.LogsticCenterList = productList
    })
  }
}
